<!-- 电站管理 -->
<template>
	<div>
		<searchBar />

		<packageTable
			class="mt10"
			:total="total"
			:tableData="tableData"
			:overflowTip="true"
			:tableOption="tableOption"
			@handleSizeChange="handleSizeChange"
			@handleCurrentChange="handleCurrentChange"
		/>
	</div>
</template>

<script lang="ts">
import { useI18n } from 'vue-i18n';
import searchBar from './components/searchBar.vue';
import packageTable from '../../../components/commentTable/index.vue';
import { defineComponent, computed, reactive, toRefs, onMounted } from 'vue';

export default defineComponent({
	name: 'PowerStationManagement',

	components: { searchBar, packageTable },

	setup() {
		const { t } = useI18n();
		const state = reactive({
			total: 0,
			tableData: [
				{
					id: 408,
					powerName: '雒文龙26215的光伏电站',
					region: '/100000/210000/211300/211302',
					regionNames: '中国/辽宁省/朝阳市/双塔区',
					country: '100000',
					province: '210000',
					city: '211300',
					area: '211302',
					countryName: '中国',
					provinceName: '辽宁省',
					cityName: '朝阳市',
					areaName: '双塔区',
					address: '辽宁省朝阳市双塔区桃花吐镇上桃花吐村三组2111号',
					longitude: 120.602715,
					latitude: 41.73168,
					timeZone: '',
					timeZoneDesc: null,
					timeZoneKey: null,
					sysType: 0,
					stationType: 0,
					settlementType: 0,
					stationVolume: 26.22,
					ongridTime: '2022-10-27',
					powerPrice: 0.38,
					owner: '雒文龙',
					ownerPhone: '15842178246',
					merchantId: 7,
					createId: null,
					createTime: '2022-10-27 00:00:00',
					status: 0,
					ongridStatus: 0,
					delineStatus: 0,
					label: '43,44,46',
					bucket: null,
					fileCode: 'https://dms-prod-public.s3.cn-northwest-1.amazonaws.com.cn/normal/20221022a533c63a345e452bb2a32e1e6dfac287.jpg',
					businessType: 0,
					azimuth: null,
					dipangle: null,
					installerId: 36,
					installerName: '辽宁晶盛低碳新能源科技有限公司',
					operationId: null,
					operationName: null,
					moduleVender: null,
					moduleVersion: null,
					stationCode: 'LG202203270003',
					installType: '0',
					installTypeStr: null,
					businessTag: 'def',
					makerStationId: null,
					auditStatus: 1,
					apiKey: '95d13e8f-b5f9-11ef-94de-005056a980a7',
					startTime: '2022-11-02',
					fromInfo: null,
				},
				{
					id: 339,
					powerName: '师的友32155的光伏电站',
					region: '/100000/140000/140200/140214',
					regionNames: '中国/山西省/大同市',
					country: '100000',
					province: '140000',
					city: '140200',
					area: '140214',
					countryName: '中国',
					provinceName: '山西省',
					cityName: '大同市',
					areaName: '云冈区',
					address: '山西省大同市云冈区西韩岭乡仝家湾村407号',
					longitude: 113.26992,
					latitude: 40.025604,
					timeZone: '',
					timeZoneDesc: null,
					timeZoneKey: null,
					sysType: 0,
					stationType: 0,
					settlementType: 0,
					stationVolume: 32.16,
					ongridTime: '2023-06-30',
					powerPrice: 0.33,
					owner: '师的友',
					ownerPhone: '13734202005',
					merchantId: 7,
					createId: null,
					createTime: '2023-06-30 00:00:00',
					status: 0,
					ongridStatus: 0,
					delineStatus: 0,
					label: '49,50,57',
					bucket: null,
					fileCode:
						'https://dms-prod-public.s3.cn-northwest-1.amazonaws.com.cn/powerStation/channelAdd/387c64c0-0e46-11ee-b93e-bb65059e49941687140525324.jpg',
					businessType: 0,
					azimuth: null,
					dipangle: null,
					installerId: 104,
					installerName: '山西全晶电力工程有限公司',
					operationId: null,
					operationName: null,
					moduleVender: null,
					moduleVersion: null,
					stationCode: 'LG202207100002',
					installType: '0',
					installTypeStr: null,
					businessTag: 'def',
					makerStationId: null,
					auditStatus: 1,
					apiKey: '95d0c0d3-b5f9-11ef-94de-005056a980a7',
					startTime: '2023-07-19',
					fromInfo: null,
				},
			],
			listLoading: true,
			queryForm: {
				pageNum: 1,
				pageSize: 10,
			},
		});

		// 表格表头配置
		const tableOption = computed(() => [
			{ prop: 'powerName', label: '电站名称' },
			{ prop: 'name', label: '' },
			// { prop: 'name', label: t('message.boxTransformerNews.pageSubstation') },
			// { prop: 'name', label: t('message.boxTransformerNews.pageBoxTransformerName') },
			// { prop: 'name', label: t('message.boxTransformerNews.pageStatus') },
		]);

		// 获取数据方法
		const fetchData = async () => {
			state.listLoading = false;
			// 实际请求示例:
			// const res = await api.fetchData(state.queryForm);
			// state.tableData = res.data.list;
			// state.total = res.data.totalCount;
		};

		// 分页方法
		const handleSizeChange = (val: number) => {
			state.queryForm.pageSize = val;
			fetchData();
		};

		const handleCurrentChange = (val: number) => {
			state.queryForm.pageNum = val;
			fetchData();
		};

		// 生命周期钩子
		onMounted(() => {
			fetchData();
		});

		return {
			...toRefs(state),
			tableOption,
			handleSizeChange,
			handleCurrentChange,
		};
	},
});
</script>

<style lang="scss" scoped></style>
